package bloomfilter;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author: feiwang_6
 * @create: 2020/7/10 15:37
 * @description:
 */
public class LRULinkedHashMap<K, V> extends LinkedHashMap<K, V> {

    //最大数据存储容量 
    private static final int LRU_MAX_CAPACITY = 1024;

    /**
     * 构造方法
     */
    public LRULinkedHashMap() {
        super(LRU_MAX_CAPACITY, (float) 0.75, true);
    }

    @Override
    protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
        if (size() > LRU_MAX_CAPACITY) {
            return true;
        }
        return false;
    }
    
    public static void main(String[] args) {
        LRULinkedHashMap<Integer, String> linkedHashMap = new LRULinkedHashMap<Integer, String>();
        linkedHashMap.put(1, "1");
        linkedHashMap.put(1, "1");
        linkedHashMap.put(1, "1");
        linkedHashMap.put(1, "1");
        
    }
}
